<template>
    <picker @change="bindPickerChange($event, index)" :value="pickerindex" :range="data">
        <view class="uni-input">{{ data[pickerindex] }}</view>
    </picker>
</template>

<script>
export default {
    props: {
        data: {
            // 数据
            type: Array,
        },
        index: {
            type: Number,
            default: 0,
        },
        activevalue: {
            type: String,
            default: "",
        },
    },
    data() {
        return {
            pickerindex: 0,
        }
    },
    mounted() {
        if (this.activevalue) {
            this.data.forEach((e, index) => {
                if (this.activevalue == e) {
                    this.pickerindex = index
                }
            })
        }
    },
    methods: {
        bindPickerChange: function (e, index) {
            this.pickerindex = e.target.value
            this.$emit("bindPickerChange", index, this.data[this.pickerindex])
        },
    },
}
</script>

<style lang="scss">
.checkmain {
    display: flex;
    flex-wrap: wrap;

    label {
        display: flex;
        width: 50%;

        view {
            white-space: nowrap;
        }
    }
}
</style>
